package com.xiaohudie.thread;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @Author xiao hu die
 * @Date 2022/2/21 18:50
 * @Version 1.0
 */
public class Test12 {
 public static void main(String[] args) throws ParseException {
  Timer timer = new Timer(true);
  SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

   Date parse = simpleDateFormat.parse("2022-02-21 18:56:00");
  timer.schedule(new LogerTime(),parse,1000*10);
 }
 static class LogerTime extends TimerTask{

  @Override
  public void run() {
   SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   String format = simpleDateFormat.format(new Date());
   System.out.println("开始执行定时任务"+ format);
  }
 }
}
